home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Plug-In Power Pack for Netscape Communicator
/
Plug-In Power Pack for Netscape Communicator.iso
/
plugins
/
dataviews
/
dvtools
/
demos
/
telecomdemo
/
sim_util.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-08
|
5KB
|
215 lines
#ifndef lint
static char SccsId[]= "@(#)sim_util.c V1.6 3/17/95";
#endif
/*
| File name: sim_util.c
|========================================================================
|
| Copyright (c) 1990 -- V.I. Corporation
|
|========================================================================
*/
#include "simulate.h"
#include "tlc_fundecl.h"
/*
* GetNamedView -- look in the view symbol table for the view indicated
* by the name.
*/
VIEW_STRUCT *
GetNamedView (name)
char *name;
{
VIEW_STRUCT *view_struct;
SYMNODE symnode;
if (name)
if ((symnode = VTstkeyfind (SimParams.view_tab, name)) != NULL)
{
view_struct = (VIEW_STRUCT *) VTsnvalue (symnode);
return view_struct;
}
return NULL;
}
/*
* GetNamedNode -- look in the node symbol table for the node indicated
* by the name.
*/
NODE_STRUCT *
GetNamedNode (name)
char *name;
{
NODE_STRUCT *node_struct;
SYMNODE symnode;
if (name)
if ((symnode = VTstkeyfind (SimParams.node_tab, name)) != NULL)
{
node_struct = (NODE_STRUCT *) VTsnvalue (symnode);
return node_struct;
}
return NULL;
}
/*
* GetNamedPart -- look in the part and switch symbol table for the part
* indicated by the name.
*/
PART_STRUCT *
GetNamedPart (name)
char *name;
{
PART_STRUCT *part_struct;
SYMNODE symnode;
if (name)
{
if ((symnode = VTstkeyfind (SimParams.part_tab, name)) == NULL)
if ((symnode = VTstkeyfind (SimParams.switch_tab, name)) == NULL)
return NULL;
part_struct = (PART_STRUCT *) VTsnvalue (symnode);
return part_struct;
}
return NULL;
}
/*
* GetNewViewStruct -- create and initialize a new view structure.
*/
VIEW_STRUCT *GetNewViewStruct
V_P_ ((void))
{
VIEW_STRUCT *view_struct;
view_struct = (VIEW_STRUCT *) S_ALLOC ((LONG) sizeof (VIEW_STRUCT));
view_struct->view_name = NULL;
view_struct->view = NULL;
view_struct->drawport = NULL;
view_struct->node_list = NULL;
view_struct->last_node = NULL;
view_struct->link_list = NULL;
view_struct->last_link = NULL;
view_struct->part_list = NULL;
view_struct->last_part = NULL;
view_struct->back_ptr = NULL;
return view_struct;
}
/*
* GetNewNodeStruct -- create and initialize a new node struct.
*/
NODE_STRUCT *GetNewNodeStruct
V_P_ ((void))
{
NODE_STRUCT *node_struct;
node_struct = (NODE_STRUCT *) S_ALLOC ((LONG) sizeof (NODE_STRUCT));
node_struct->node_name = NULL;
node_struct->status = NORMAL;
node_struct->switch_list = NULL;
node_struct->last_switch = NULL;
node_struct->softerror_count = 0;
node_struct->critical_count = 0;
node_struct->failure_count = 0;
node_struct->next = NULL;
node_struct->view_ptr = NULL;
node_struct->back_ptr = NULL;
return node_struct;
}
/*
* GetNewLinkStruct -- create and initialize a new link struct.
*/
LINK_STRUCT *GetNewLinkStruct
V_P_ ((void))
{
LINK_STRUCT *link_struct;
link_struct = (LINK_STRUCT *) S_ALLOC ((LONG) sizeof (LINK_STRUCT));
link_struct->link_name = NULL;
link_struct->status = NORMAL;
link_struct->node1_name = NULL;
link_struct->node2_name = NULL;
link_struct->next = NULL;
link_struct->switch1 = NULL;
link_struct->switch2 = NULL;
link_struct->back_ptr = NULL;
return link_struct;
}
/*
* GetNewPartStruct -- create and initialze a new part structure.
*/
PART_STRUCT *GetNewPartStruct
V_P_ ((void))
{
PART_STRUCT *part_struct;
part_struct = (PART_STRUCT *) S_ALLOC ((LONG) sizeof (PART_STRUCT));
part_struct->part_name = NULL;
part_struct->status = NORMAL;
part_struct->error_time = 0;
part_struct->fix_time = 0;
part_struct->err_prop = NULL;
part_struct->node_name = NULL;
part_struct->next = NULL;
part_struct->next_switch = NULL;
part_struct->primary_node = NULL;
part_struct->back_ptr = NULL;
return part_struct;
}
/*
* get_token -- get the next token from a string. The token delimiter
* is an asterisk. Put a null in place of the delimiter and return a
* pointer to the beginning of the next token.
*/
void
get_token (start, result, next)
char *start;
char **result;
char **next;
{
CHAR *cptr;
if ((cptr = S_STR_INDEX (start, '*')) != NULL)
{
*cptr = '\0';
*next = cptr + 1;
*result = start;
}
else
{
*next = NULL;
*result = start;
}
}
/*
* SetNumberString -- set the value of the string in a vector text object
* to be a representation of a numeric value.
*/
void
SetNumberString (object, num)
OBJECT object;
int num;
{
CHAR tmp_str[30];
(VOID) sprintf (tmp_str, "%d", num);
VOvtSetString (object, tmp_str);
}